package com.mjk.manager.gen.impl.ui;

import com.mjk.common.base.model.BaseEntity;
import com.mjk.common.core.jdbc.util.TableUtils;
import com.mjk.manager.gen.dto.GenDto;

/**
 * vue代码生成
 * @author Administrator
 *
 */
public class JsGenerate implements IUiGen{
	
	@Override
	public boolean isVaild() {
		return false;
	}
	
	@Override
	public Class<?> createClass(GenDto model) {
		return null;
	}
	/**
	 * 生成JS 代码字符串
     */
	public String getJsGenerate(BaseEntity entity){
	        String str=
	                "import config from \"@/config\"" +WRAP+
	                "import http from \"@/utils/request\"" +WRAP+
	                "import stringutil from \"@/utils/string\";" +WRAP+
	                "export default {" +WRAP+
	                "  list: {" +WRAP+
	                TAB+" url: `${config.API_URL}/#modelL/list`," +WRAP+
	                TAB+" name: \"列表\"," +WRAP+
	                TAB+" get: async function(params){" +WRAP+
	                TAB+" return await http.get(this.url, params, {" +WRAP+
	                TAB_2+"   headers: stringutil.getHeader()" +WRAP+
	                TAB+"    });" +WRAP+
	                TAB+" }" +WRAP+
	                SPACE+ "}," +WRAP+
	                "  doDel: {" +WRAP+
	                TAB+" url: `${config.API_URL}/#modelL/doDel`," +WRAP+
	                TAB+" name: \"删除\"," +WRAP+
	                TAB+" get: async function(data){" +WRAP+
	                TAB+SPACE+" return await http.get(this.url, data, {" +WRAP+
	                TAB_2+"   headers: stringutil.getHeader()" +WRAP+
	                TAB+"    });" +WRAP+
	                TAB+" }" +WRAP+
	                SPACE+" }," +WRAP+
	                "  add: {" +WRAP+
	                TAB+" url: `${config.API_URL}/#modelL/add`," +WRAP+
	                TAB+" name: \"新增\"," +WRAP+
	                TAB+" get: async function(data){" +WRAP+
	                TAB+" \treturn await http.get(this.url, data, {" +WRAP+
	                TAB_2+"   headers: stringutil.getHeader()" +WRAP+
	                TAB+"    });" +WRAP+
	                TAB+" }" +WRAP+
	                SPACE+" }," +WRAP+
	                "  doSave: {" +WRAP+
	                TAB+" url: `${config.API_URL}/#modelL/doSave`," +WRAP+
	                TAB+" name: \"保存\"," +WRAP+
	                TAB+" post: async function(data){" +WRAP+
	                TAB+" \treturn await http.post(this.url, data, {" +WRAP+
	                TAB_2+"   headers: stringutil.getHeader()" +WRAP+
	                TAB+"    });" +WRAP+
	                TAB+" }" +WRAP+
	                SPACE+" }," +WRAP+WRAP+
	                "}";
	        str=str.replace("#modelL", TableUtils.getTableName(entity));
	        return str;
	    }
}
